using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.MedicalDomain;
using ShivamEMR.Model.DataInterfaces.MedicalDataInterf;
using ShivamEMR.Model;


namespace ShivamEMR.Web.Areas.Medical.Controllers
{   
    public class RadiologyGroupController : Controller
    {
		private readonly IRadiologyGroupRepository radiologygroupRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public RadiologyGroupController() //: this(new RadiologyGroupRepository())
        {
            this.radiologygroupRepository = Registry.RepositoryFactory.GetRadiologyGroupRepository();
        }

        public RadiologyGroupController(IRadiologyGroupRepository radiologygroupRepository)
        {
			this.radiologygroupRepository = radiologygroupRepository;
        }

        //
        // GET: /RadiologyGroup/

        public ViewResult Index()
        {
            return View(radiologygroupRepository.All);//Including(radiologygroup => radiologygroup.Parent, radiologygroup => radiologygroup.Children, radiologygroup => radiologygroup.Radiologies, radiologygroup => radiologygroup.Attachments));
        }

        //
        // GET: /RadiologyGroup/Details/5

        public ViewResult Details(int id)
        {
            return View(radiologygroupRepository.Find(id));
        }

        //
        // GET: /RadiologyGroup/Create

        public ActionResult Create()
        {
			ViewBag.PossibleParents = radiologygroupRepository.All;
            return View();
        } 

        //
        // POST: /RadiologyGroup/Create

        [HttpPost]
        public ActionResult Create(RadiologyGroup radiologygroup)
        {
            if (ModelState.IsValid) {
                radiologygroupRepository.InsertOrUpdate(radiologygroup);
                radiologygroupRepository.Save();
                return RedirectToAction("Index");
            } else {
				ViewBag.PossibleParents = radiologygroupRepository.All;
				return View();
			}
        }
        
        //
        // GET: /RadiologyGroup/Edit/5
 
        public ActionResult Edit(int id)
        {
			ViewBag.PossibleParents = radiologygroupRepository.All;
             return View(radiologygroupRepository.Find(id));
        }

        //
        // POST: /RadiologyGroup/Edit/5

        [HttpPost]
        public ActionResult Edit(RadiologyGroup radiologygroup)
        {
            if (ModelState.IsValid) {
                radiologygroupRepository.InsertOrUpdate(radiologygroup);
                radiologygroupRepository.Save();
                return RedirectToAction("Index");
            } else {
				ViewBag.PossibleParents = radiologygroupRepository.All;
				return View();
			}
        }

        //
        // GET: /RadiologyGroup/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View(radiologygroupRepository.Find(id));
        }

        //
        // POST: /RadiologyGroup/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            var r = radiologygroupRepository.Find(id);
            radiologygroupRepository.Delete(r);
            radiologygroupRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

